package com;

import com.example.example01.HadoopMapReduceDrive;
import com.example.example02.SpeakerDriver;
import com.example.example04.RawLogDriver;
import com.tasks.task01.NumberSortDrive;
import org.apache.log4j.Logger;

import java.io.File;
import java.io.IOException;


/**
 * Hello world!
 *
 */
public class App 
{
  // 日志记录
  private static final Logger logger = Logger.getLogger(App.class);
 // parent work folder
  private static final String WORK_PATH = "hadoop-example\\src\\main\\resources";
  /**
 * 启动方法
 * 
 * @param args
 */
  public static void main( String[] args ) throws IOException, ClassNotFoundException, InterruptedException {
    test01();
  }

  /**
   * word count 示例
   * 
   */
  public static void example01() throws IOException, ClassNotFoundException, InterruptedException {
    String sources = "E:\\Github\\Java\\lagou.bigdata.learn.yk\\project\\example\\demo\\__temp__\\wordcount.txt";
    String target = "E:\\Github\\Java\\lagou.bigdata.learn.yk\\project\\example\\demo\\__temp__\\wordcount_output";
    HadoopMapReduceDrive mrTest = new HadoopMapReduceDrive();
    mrTest.Start(sources, target);
  }
  /**
   * 
   * 
   */
  public static void example2() throws IOException, ClassNotFoundException, InterruptedException {
    String sources = "E:\\Github\\Java\\lagou.bigdata.learn.yk\\project\\example\\demo\\__temp__\\wordcount.txt";
    String target = "E:\\Github\\Java\\lagou.bigdata.learn.yk\\project\\example\\demo\\__temp__\\wordcount_output";
    SpeakerDriver mrTest = new SpeakerDriver();
    mrTest.Start(sources, target);
  }
  public static void example3() throws IOException, ClassNotFoundException, InterruptedException {
    String sources = "E:\\Github\\Java\\lagou.bigdata.learn.yk\\project\\example\\demo\\__temp__\\wordcount.txt";
    String target = "E:\\Github\\Java\\lagou.bigdata.learn.yk\\project\\example\\demo\\__temp__\\wordcount_output";
    com.example.example03.SpeakerDriver mrTest = new com.example.example03.SpeakerDriver();
    mrTest.Start(sources, target);
  }
  public static void example4() throws IOException, ClassNotFoundException, InterruptedException {
    String sources = "E:\\Github\\Java\\lagou.bigdata.learn.yk\\project\\example\\demo\\__temp__\\wordcount.txt";
    String target = "E:\\Github\\Java\\lagou.bigdata.learn.yk\\project\\example\\demo\\__temp__\\wordcount_output";
    RawLogDriver mrTest = new RawLogDriver();
    mrTest.Start(sources, target);
  }
  public static void test01() throws IOException, ClassNotFoundException, InterruptedException {
      String sources = WORK_PATH + "\\tasks\\task01\\input\\*";
      String target = WORK_PATH + "\\tasks\\task01\\output\\output02";
      // 如果目标文件夹已经存在，则直接删除
      File outPutTarget = new File(target);
      outPutTarget.deleteOnExit();
      NumberSortDrive mrTest = new NumberSortDrive();
      mrTest.Start(sources, target);
  }
}
